// vite.config.ts
// -------------------- React 相关插件 --------------------
import AutoImport from "unplugin-auto-import/vite"
import Components from "unplugin-react-components/vite"
import viteTsconfigPaths from "vite-tsconfig-paths"

// -------------------- Vite 核心与工具插件 --------------------
import { inspectorServer } from "@react-dev-inspector/vite-plugin"
import tailwindcss from "@tailwindcss/vite"
import react from "@vitejs/plugin-react"
import { defineConfig, type PluginOption } from "vite"

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    react(),
    tailwindcss(),
    inspectorServer() as PluginOption, // React Dev Inspector 插件
    Components({
      include: [/\.tsx$/, /\.jsx$/],
      exclude: [/node_modules/],
      dts: {
        filename: "./src/types/auto-components",
      },
    }),
    AutoImport({
      dts: "./src/types/auto-imports.d.ts",
      imports: ["react", "react-router"],
    }),
    viteTsconfigPaths(), // 自动识别 tsconfig 路径别名
  ],
  define: {
    // 生产环境下启用 hydration mismatch 详细信息
    __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "true",
  },
})
